﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Media.Animation;

namespace DiagnosticAndMonitorinApp
{
    /// <summary>
    /// Lógica de interacción para Animacion.xaml
    /// </summary>
    public partial class Animacion : UserControl
    {
        Storyboard sb;
        public Animacion()
        {
            InitializeComponent();
            this.MouseEnter += new MouseEventHandler(Animacion_MouseEnter);
        }

        void Animacion_MouseEnter(object sender, MouseEventArgs e)
        {   
            AnimateLabel(); 
        }

        private  void AnimateLabel( )
        {

            DoubleAnimation AnimationEntrada1 = new DoubleAnimation();
            AnimationEntrada1.From =0;
            AnimationEntrada1.To = this.ActualHeight;
            AnimationEntrada1.Duration = new Duration(new TimeSpan(0, 0, 0, 1, 0));
            AnimationEntrada1.BeginTime = new TimeSpan(0, 0, 0, 5);
         

            DoubleAnimation AnimationSalida1 = new DoubleAnimation();
            AnimationSalida1.From = this.ActualHeight;
            AnimationSalida1.To = 0;
            AnimationSalida1.Duration = new Duration(new TimeSpan(0, 0, 0, 1, 0));
            AnimationSalida1.BeginTime = new TimeSpan(0, 0, 0, 10);
         

            DoubleAnimation AnimationEntrada2  = new DoubleAnimation();
            AnimationEntrada2.From = 0;
            AnimationEntrada2.To = this.ActualHeight;
            AnimationEntrada2.Duration = new Duration(new TimeSpan(0, 0, 0, 1, 0));
            AnimationEntrada2.BeginTime = new TimeSpan(0, 0, 0, 15);


            DoubleAnimation AnimationSalida2 = new DoubleAnimation();
            AnimationSalida2.From = this.ActualHeight;
            AnimationSalida2.To = 0;
            AnimationSalida2.Duration = new Duration(new TimeSpan(0, 0, 0, 1, 0));
            AnimationSalida2.BeginTime = new TimeSpan(0, 0, 0, 20);
         

           sb = new Storyboard();

            Storyboard.SetTarget(AnimationEntrada1, L1);
            Storyboard.SetTargetProperty(AnimationEntrada1, new PropertyPath("(Height)"));
            
            Storyboard.SetTarget(AnimationSalida1, L1);
            Storyboard.SetTargetProperty(AnimationSalida1, new PropertyPath("(Height)"));
            
            Storyboard.SetTarget(AnimationEntrada2, L2);
            Storyboard.SetTargetProperty(AnimationEntrada2, new PropertyPath("(Height)"));

            Storyboard.SetTarget(AnimationSalida2, L2);
            Storyboard.SetTargetProperty(AnimationSalida2, new PropertyPath("(Height)"));
            


            //sb.BeginTime = new TimeSpan(0, 0, 0, 5);


            sb.Children.Add(AnimationEntrada1);
            sb.Children.Add(AnimationSalida1);
            sb.Children.Add(AnimationEntrada2);
            sb.Children.Add(AnimationSalida2);
             
            sb.RepeatBehavior = new RepeatBehavior(1);

            sb.Completed += new EventHandler(sb_Completed);
            sb.Begin();

           
        }

        void sb_Completed(object sender, EventArgs e)
        {
            sb.Stop();
            sb.Begin();


        }

                       
       
    }
}
